"use strict";

/**
 * @ngdoc function
 * @name jgappApp.controller:AttendanceAttendanceStatisticdetailCtrl
 * @description
 * # AttendanceAttendanceStatisticdetailCtrl
 * Controller of the jgappApp
 */
angular
  .module("jgappApp")
  .controller("AttendanceAttendanceStatisticdetailCtrl", function(
    $location,
    DataService,
    openApi,
    localStorageService
  ) {
    var vm = this;
    vm.map = [
      {
        value: 1,
        name: "正常天数",
        key: "normal"
      },
      {
        value: 2,
        name: "迟到",
        key: "lateam"
      },
      {
        value: 3,
        name: "早退",
        key: "earlypm"
      },
      // {
      //     value: 4,
      //     name: "未签到",
      //     key: "unsignam"
      // }, {
      //     value: 5,
      //     name: "未签退",
      //     key: "unsignpm"
      // },
      {
        value: 0,
        name: "范围外",
        key: "rangeoutside"
      },
      {
        value: 4,
        name: "加班",
        key: "overtime"
      }
    ];
    // 进入详情
    this.goDetail = function(value, type) {
      if (vm.info[value] > 0) {
        localStorageService.set("attLog", vm.currentDate);
        $location.path("attendance/attendance_log/" + type);
      }
    };
    vm.getCurrentDataFromDate = function() {
      var param = {};
      param.acId = vm.currentDate.value;
      param.year = vm.currentDate.name;
      param.month = vm.currentDate.text;
      DataService.getData(openApi.attendanceLog, param).then(function(data) {
        vm.info = data;
      });
    };
    var getcurrentDate = function() {
      DataService.getData(openApi.attendanceLoglist).then(function(data) {
        vm.datelists = data;
        vm.currentDate = vm.datelists[0];
        vm.getCurrentDataFromDate();
      });
    };
    var init = function() {
      getcurrentDate();
    };
    init();
  });
